// Copyright (c) 2023 Proton Technologies AG
//
// This file is part of Proton Mail.
//
// Proton Mail is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Proton Mail is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Proton Mail. If not, see https://www.gnu.org/licenses/.

import ProtonCoreDataModel
import XCTest

@testable import ProtonMail

final class KeyExtensionTests: XCTestCase {

    func testShortFingerprint() throws {
        let key = Key(keyID: "aaa", privateKey: privateKey())
        XCTAssertEqual(key.shortFingerprint, "0x5D9A4103")
    }

    // Generated by MailCrypto.generateRandomKeyPair()
    private func privateKey() -> String {
        "-----BEGIN PGP PRIVATE KEY BLOCK-----\nVersion: GopenPGP 2.5.0\nComment: https://gopenpgp.org\n\nxYYEY+8x+hYJKwYBBAHaRw8BAQdAClNY5grIa+9A1yJUB+WEoa1YqHEv9Y9kY2Ye\n9drO7Fj+CQMI/6nqJsFlQyBgm8sfTguiRcyg155wS4f+iYrB8URfrTK04OZVmHFa\nbfbbQvFo9YUwoI0W6V9+KOjh6SSuNt1oTna0eEMkSP2eMop1glGEQM1aM0YzM0Qz\nMTgtMDhCRC00RUY1LTlCMTktMzQxQ0Y0RDYwMzRDIDwzRjMzRDMxOC0wOEJELTRF\nRjUtOUIxOS0zNDFDRjRENjAzNENAcHJvdG9ubWFpbC5jb20+wowEExYIAD4FAmPv\nMfoJkEu+OJt0lLWNFiEEXZpBA/sP2D9gRgC8S744m3SUtY0CGwMCHgECGQEDCwkH\nAhUIAxYAAgIiAQAAHTQBANQuLTT/nojjTm4a9vOUmuJ6gGrXwv3LUXbSdriDfNVN\nAQD+Yz6IV+cdFfrnM2R7Ckb3gzGZHOPibmRyDLYr8ssZDceLBGPvMfoSCisGAQQB\nl1UBBQEBB0Ag1zLHTZs6+ohzsVAPteVac/TABgwyWVuUh9ZCnK5FWAMBCgn+CQMI\nfKQAON4aJw5gUKI70IVWwX1k/jWRnvHcPgyEDstND10njVhKuMX51cciUiB7O7hq\nD+QYf9fbus4qv1wEJxuZaGgaKdH05AyWvqUT7kZQKMJ4BBgWCAAqBQJj7zH6CZBL\nvjibdJS1jRYhBF2aQQP7D9g/YEYAvEu+OJt0lLWNAhsMAACumgEA0RvagIs7Vsvt\n5wceDHrYIASpSP6YEC6pMHVvILHJEh4A/AhQVe7UTHnOFTfq61SB01C5snIF4S9s\n8u81+Jzo408J\n=Yz3C\n-----END PGP PRIVATE KEY BLOCK-----"
    }
}
